package com.bf.electroplating.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bf.electroplating.pojo.dto.IdDTO;
import com.bf.electroplating.pojo.dto.contingency.ParkContingencyTeamDTO;
import com.bf.electroplating.pojo.dto.contingency.ParkContingencyTeamQueryDTO;
import com.bf.electroplating.pojo.vo.ResultVO;
import com.bf.electroplating.pojo.vo.contingency.ParkContingencyTeamVO;
import com.bf.electroplating.service.ParkContingencyTeamService;
import com.bf.electroplating.util.idempotent.Idempotent;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "应急队伍管理")
@RestController
@RequestMapping("/parkContingencyTeam")
public class ParkContingencyTeamController {

    @Resource
    private ParkContingencyTeamService parkContingencyTeamService;

    @Idempotent
    @Operation(summary = "新增应急队伍")
    @PostMapping("/add")
    public ResultVO<Void> add(@RequestBody ParkContingencyTeamDTO dto) {
        parkContingencyTeamService.add(dto);
        return ResultVO.ok(null, "保存成功");
    }

    @Idempotent
    @Operation(summary = "更新应急队伍")
    @PostMapping("/update")
    public ResultVO<Void> update(@RequestBody ParkContingencyTeamDTO dto) {
        parkContingencyTeamService.update(dto);
        return ResultVO.ok(null, "保存成功");
    }

    @Operation(summary = "分页查询应急队伍")
    @PostMapping("/page")
    public ResultVO<Page<ParkContingencyTeamVO>> page(@RequestBody ParkContingencyTeamQueryDTO dto) {
        return ResultVO.ok(parkContingencyTeamService.page(dto));
    }

    @Operation(summary = "删除应急队伍")
    @PostMapping("/delete")
    public ResultVO<Void> delete(@RequestBody IdDTO idDTO) {
        parkContingencyTeamService.delete(idDTO.getId());
        return ResultVO.ok(null, "删除成功");
    }

    @PostMapping("/detail")
    @Operation(summary = "应急队伍详情", description = "应急队伍详情")
    public ResultVO<ParkContingencyTeamDTO> getDetail(@RequestBody IdDTO idDTO) {
        return parkContingencyTeamService.getDetail(idDTO.getId());
    }

    @PostMapping("/batch")
    @Operation(summary = "批量删除", description = "批量删除")
    public ResultVO<Boolean> batchDelete(@RequestBody List<String> ids) {
        return ResultVO.ok(parkContingencyTeamService.batchDelete(ids), "删除成功");
    }

} 